home *** CD-ROM | disk | FTP | other *** search
/ World of Sound / World of Sound.iso / utils / miditools / kawaied / src / singleed.c < prev    next >
C/C++ Source or Header  |  1992-10-22  |  46KB  |  1,698 lines

  1. #include "inc.h"
  2. #include "defs.h"
  3. #include "req_manx_5.c"
  4. #include "zz_pointer.h"
  5. #include <exec/memory.h>
  6.  
  7. extern struct Image     Image1;
  8. extern struct Gadget    Gadget1; 
  9. extern struct PropInfo    Gadget1SInfo; 
  10. extern int initsing[88];
  11.  
  12. struct     GetStringStruct strstruct;                
  13.  
  14. char *WaveName[256] =
  15. {    "Sine 1st","Sine 2nd","Sine 3rd","Sine 4th","Sine 5th","Sine 6th","Sine 7th",
  16.     "Sine 8th","Sine 9th","Sine 10th","Sine 11th","Sine 12th","Sine 16th","Saw 1",
  17.     "Saw 2","Saw 3","Saw 4","Saw 5","Saw 6","Saw 7","Saw 8","Saw 9","Saw 10",
  18.     "Saw 11","Saw 12","Saw 13","Saw 14","Saw 15","Saw 16","Saw 17","Saw 18","Saw 19",
  19.     "Square 1","Square 2","Square 3","Square 4","Square 5","Inverse-Saw","Triangle",
  20.     "Random",
  21.     "French Horn","String 1","String 2","String Pad","Piano 1","El.Grand",
  22.     "E.Piano 1","E.Piano 2","E.Piano 3","Clavi","Vibe","A.Guitar","F.Guitar 1",
  23.     "F.Guitar 2","Ac Bass 1","Ac Bass 2","Digi Bass 1","Pick Bass","Digi Bass 2",
  24.     "Round Bass","Fretless 1","Fretless 2","Flute","Panflute","Harmonica","Glocken",
  25.     "Tine","Harp","Marimba","E.Tom","Log Drum","Jazz Organ 1","Mello Pad",
  26.     "Synth Solo","Synth 2",
  27.     "French Horn 1","French Horn 2","Brass 1","Brass 2","Brass 3","Brass 4",
  28.     "Trumpet 1","Trumpet 2","Violin","String","Piano 1","Piano 2","Piano 3",
  29.     "Piano 2b","Piano 3b","Piano 4","Piano 4b","El.Grand","E.Piano 1","E.Piano 2",
  30.     "E.Piano 3","Clavi","Harpsichord","Vibe","A.Guitar","F.Guitar","Strat 1",
  31.     "Strat 2","Ac Bass","Pull Bass 1","Pull Bass 2","Round Bass","Slap Bass 1",
  32.     "Slap Bass 2","Slap Bass 3","Fretless 1","Fretless 2","Synth Bass 1",
  33.     "Synth Bass 2","Harmonica","Clarinet 1","Clarinet 2","Oboe 1","Oboe 2",
  34.     "Shakuhachi","Oriental Bell 1","Oriental Bell 2","Bell","Koto","Sitar",
  35.     "E.Tom","Log Drum 1","Log Drum 2","Steel Drum 1","Steel Drum 2","Voice 1",
  36.     "Voice 2","Accordion 1","Accordion 2","Jazz Organ 2","Rock Organ 1","Draw Bar 1",
  37.     "Draw Bar 2","Pipe Organ 1","Pipe Organ 2","Rock Organ 2","Synth Solo 1",
  38.     "Synth Solo 2","Synth 2","Synth 2b","Synth 3",
  39.     "Brass 1","Brass 2","Orchestra","Piano 1","Piano 4","E.Piano 1","E.Piano 1b",
  40.     "E.Piano 2","E.Piano 3","Clavi","Harpsichord 1","Harpsichord 2","Vibe",
  41.     "Digi Bass 1","Digi Bass 2","Digi Bass 2b","Pick Bass","Glocken 1","Glocken 2",
  42.     "Tine 1","Tine 2","Tine 3","Tube Bell 1","Tube Bell 2","Tube Bell 3",
  43.     "Xylophone 1","Xylophone 2","Harp","Koto","Sitar 1","Sitar 2","Kalimba 1",
  44.     "Kalimba 2","Kalimba 3","Log Drum","Steel Drum","Pipe Organ 3","Pipe Organ 3b",
  45.     "Synth 1","Synth 2","Synth 3","Synth 3b","Synth 4","Synth 4b",
  46.     "Clavi","Digi Bass 1","Digi Bass 2","Pick Bass 1","Pick Bass 2","Round Bass 1",
  47.     "Round Bass 2","Harmonica 1","Harmonica 2","Harp","Koto","Sitar","Marimba",
  48.     "Synth 1",
  49.     "Bass Drum","Ac Snare","Tight Snare","E.Snare","Rim","Ac Tom","HiHat","Crash",
  50.     "Ride","Strat Guitar","Fuzz Mute","A.Guitar","F.Guitar","Guitar Harmo","Pull Bass",
  51.     "Bass Harmo","Bowed String","String Attack","String Sus","Pizzicato","Piano",
  52.     "El.Grand","Piano Noise","Trumpet","Shakuhachi Att","Shakuhachi Sus","Panflute Att",
  53.     "Panflute Sus","Voice","White Noise",
  54.     "String Loop","Shakuhachi Loop","Panflute Loop","Voice Loop","White Noise Loop",
  55.     "Ac Snare Loop","F.Guitar Loop","Pull Bass Loop",
  56.     "Omni Loop 1","Omni Loop 2","Omni Loop 3","Omni Loop 4","Omni Loop 5","Omni Loop 6",
  57.     "Omni Loop 7","Omni Loop 8",
  58.     "Ac Snare Rev","Ac Tom Rev","F.Guitar Rev",
  59.     "HiHat Alt","Crash Alt","Piano Noise Alt"
  60. };
  61.  
  62. char *ShapeName[4]={"Tri","Saw","Sqr","Rnd"};
  63. char *ModName[6]={"Off","2>1","1>2","Off","4>3","3>4"};
  64. char *PolyName[3]={"Poly 1","Poly 2"," Solo "};
  65. extern char *ToneName[12];
  66.  
  67. WORD areabuffer[250];
  68. struct TmpRas tmp;
  69. struct AreaInfo areainfo;
  70. long mem;
  71.  
  72. int VCvec[8][8] =
  73. {    1,32,1,32,130,1,130,1,                    /* die Velocity-Kurven */
  74.     1,32,43,18,86,6,130,1,
  75.     1,32,43,27,86,18,130,1,
  76.     1,32,78,26,104,17,130,1,
  77.     1,32,60,32,112,3,130,1,
  78.     1,32,31,28,100,5,130,1,
  79.     1,32,30,16,100,9,130,1,
  80.     1,1,65,1,100,32,130,32
  81. };
  82.  
  83. int    KSCvec[5][8] =
  84. {    1,32,1,32,130,1,130,1,                    /* die 5 KS-Kurven */
  85.     1,32,43,27,86,18,130,1,
  86.     1,32,43,18,86,6,130,1,
  87.     1,32,50,32,80,1,130,1,
  88.     1,32,65,32,65,1,130,1
  89. };
  90.  
  91. int volume;
  92. int polymode;
  93. int sources;
  94. int ams1,ams2;
  95. int prsfreq;
  96. int vibdepth;
  97. int vibpres;
  98. int pitchbend;
  99. int lfospeed;
  100. int lfoshape;
  101. int kscurve;
  102. int vibwheel;
  103. int autodepth;
  104. int autotime;
  105. int autobendvel;
  106. int autobendks;
  107.  
  108. int mute[4];
  109. int fine[4];
  110. int coarse[4];
  111. int wave[4];
  112. int keytrack[4];
  113. int vibabend[4];
  114. int prsonfreq[4];
  115. int velcurve[4];
  116. int envlevel[4];
  117. int envdelay[4];
  118. int envattack[4];
  119. int envdecay[4];
  120. int envsustain[4];
  121. int envrelease[4];
  122. int levelmodvel[4];
  123. int levelmodprs[4];
  124. int levelmodks[4];
  125. int timemodvel[4];
  126. int timemodks[4];
  127. int freqksfreq[4];
  128.  
  129. extern int oldenvlevel[4];
  130. extern int oldenvdelay[4];
  131. extern int oldenvattack[4];
  132. extern int oldenvdecay[4];
  133. extern int oldenvsustain[4];
  134. extern int oldenvrelease[4];
  135.  
  136. unsigned char f[88];
  137. int oldvol;
  138.  
  139. /* singleed.c */
  140. void DecodeSingle(const int nr);
  141. void SingleEd(const int nr);
  142. void SingleProp(int current, int max, int flag,int nr);
  143. void EncodeSingle(const int nr);
  144. void NumBox(int x, int y,int wide,char *, int val);
  145. int Check(int x, int y, int xmin, int xmax, int ymin, int ymax);
  146. void DisplaySingleLine(int pos);
  147. void MakeBox(struct Window *win,long x1,long y1,long x2,long y2);
  148. void MakeDBox(struct Window *win,long x1,long y1,long x2,long y2);
  149. void DisplaySingleValue(const int,const long);
  150. void ReturnValue(const int,const int,const long );
  151. void SingleParameterSend(int nr,int src,int val);
  152. void TestSound(int channel);
  153. void Oscillators(void);
  154. void Swap(int *a,int *b);
  155.  
  156. /**********************************************************************************/
  157. /***                                                                            ***/
  158. /**********************************************************************************/
  159.  
  160. void DecodeSingle(const int nr)
  161. {
  162.     int i,S[88];
  163.  
  164.     for (i=0;i<=87;i++) S[i]=s[nr/32][nr%32][i];
  165.  
  166.     volume    =S[10];
  167.     polymode=S[11] & 3;
  168.     sources    =(S[11] & 4) >> 2;
  169.     ams1    =(S[11] & 24) >> 3; 
  170.     ams2    =(S[11] & 96) >> 5;
  171.  
  172.     prsfreq        =S[12];
  173.     vibdepth    =S[13];    
  174.     vibpres        =S[14];
  175.     pitchbend    =S[15];
  176.     lfospeed    =S[16];
  177.  
  178.     lfoshape    =S[17]&3;
  179.     kscurve        =(S[17]&28)>>2;
  180.     vibwheel    =(S[17]&96)>>5;
  181.  
  182.     autodepth    =S[18];
  183.     autotime    =S[19];
  184.     autobendvel    =S[20];
  185.     autobendks    =S[21];
  186.     
  187.     mute[0]        =(S[22]&1);
  188.     mute[1]        =(S[22]&2)>>1;
  189.     mute[2]        =(S[22]&4)>>2;
  190.     mute[3]        =(S[22]&8)>>3;
  191.  
  192.     for (i=0;i<=3;i++)
  193.     {
  194.         fine[i]            =S[23+i];
  195.         coarse[i]        =S[27+i];    
  196.         wave[i]            =S[31+i]+(S[35+i]&1)*128;
  197.         keytrack[i]        =(S[35+i]&2)>>1;
  198.         vibabend[i]        =(S[35+i]&4)>>2;
  199.         prsonfreq[i]    =(S[35+i]&8)>>3;
  200.         velcurve[i]        =(S[35+i]&112)>>4;
  201.         envlevel[i]        =S[39+i];
  202.         envdelay[i]        =S[43+i];
  203.         envattack[i]    =S[47+i];
  204.         envdecay[i]        =S[51+i];
  205.         envsustain[i]    =S[55+i];
  206.         envrelease[i]    =S[59+i];
  207.  
  208.         levelmodvel[i]    =S[63+i];
  209.         levelmodprs[i]    =S[67+i];
  210.         levelmodks[i]    =S[71+i];
  211.         timemodvel[i]    =S[75+i];
  212.         timemodks[i]    =S[79+i];
  213.         freqksfreq[i]    =S[83+i];
  214.     }
  215. }
  216.  
  217. /**********************************************************************************/
  218. /***                                                                            ***/
  219. /**********************************************************************************/
  220.  
  221. void SingleEd(const int nr)
  222. {
  223.     int i,refresh;
  224.     int x,y;    
  225.     char name[11],title[255];    
  226.  
  227.     oldvol=Gadget1SInfo.VertPot;
  228.     for (i=0;i<=87;i++) f[i]=s[nr/32][nr%32][i];          /* Daten sichern für Cancel */
  229.  
  230.     DecodeSingle(nr);
  231.  
  232.     for (i=0;i<=3;i++)
  233.     {
  234.         oldenvlevel[i]=     -1;
  235.         oldenvdelay[i]=     -1;
  236.         oldenvattack[i]= -1;
  237.         oldenvdecay[i]=     -1;
  238.         oldenvsustain[i]=-1;
  239.         oldenvrelease[i]=-1;
  240.     }
  241.     
  242.     SetAPen(win->RPort,0);
  243.     SetBPen(win->RPort,0);    
  244.     SetOPen(win->RPort,0);
  245.     RectFill(win->RPort,10,11,616,250);
  246.  
  247.     mem=AllocRaster(640,256);
  248.     InitArea(&areainfo,areabuffer,100);
  249.     InitTmpRas(&tmp,mem,RASSIZE(640,256));
  250.     rp->TmpRas=&tmp;
  251.     rp->AreaInfo=&areainfo;
  252.  
  253.     refresh=0;    
  254.  
  255. aufbau: ;
  256.     for (i=0;i<=9;i++) name[i]=s[nr/32][nr%32][i]; name[10]='\0';
  257.     strcpy(title,"KAWAI K1-II Librarian...Singlepatch-Editor    Selected: ");
  258.     strcat(title,name);
  259.     SetTitle(title);
  260.  
  261.     Print(win,571,21," O K ");
  262.     MakeDBox(win,567,13,614,23);
  263.  
  264.     Print(win,562,35,"Undo");
  265.     MakeDBox(win,548,27,606,37);
  266.  
  267.     Print(win,557,50,"Print");
  268.     MakeDBox(win,548,42,606,52);
  269.  
  270.     Print(win,553,65,"Rename");
  271.     MakeDBox(win,548,57,606,67);
  272.  
  273.     Print(win,562,80,"Init");
  274.     MakeDBox(win,548,72,606,82);
  275.  
  276.     Print(win,562,95,"Test");
  277.     MakeDBox(win,548,87,606,97);
  278.  
  279.     Print(win,497,35,"Load");
  280.     MakeDBox(win,483,27,541,37);
  281.  
  282.     Print(win,497,50,"Save");
  283.     MakeDBox(win,483,42,541,52);
  284.  
  285.     Print(win,488,65,"P-Copy");
  286.     MakeDBox(win,483,57,541,67);
  287.  
  288.     Print(win,488,80,"P-Swap");
  289.     MakeDBox(win,483,72,541,82);
  290.  
  291.     Print(win,488,95,"Oscil.");
  292.     MakeDBox(win,483,87,541,97);
  293.  
  294.     Gadget1SInfo.VertPot=65535-volume*656;
  295.     RefreshGadgets(&Gadget1,win,NULL); 
  296.     TransmitSingleSound(nr);
  297.  
  298. start: ;
  299.     for(i=0;i<=4;i++) DisplaySingleLine(i);
  300.     EnvDisplay();    
  301.  
  302.     if (refresh != 0) 
  303.     {
  304.         Forbid();
  305.         BeginRefresh(win);
  306.         RefreshWindowFrame(win);
  307.         EndRefresh(win,i);
  308.         Permit();
  309.         refresh=0;
  310.     }
  311.  
  312. Loop: ; 
  313.     MODWIN
  314.     WaitPort(win->UserPort);
  315.     while(mesg = (struct IntuiMessage *) GetMsg(win->UserPort))
  316.     {
  317.         class=mesg->Class;
  318.         code=mesg->Code;
  319.         x=mesg->MouseX;
  320.         y=mesg->MouseY;
  321.         ReplyMsg((struct Message *)mesg);
  322.     
  323.         switch(class)
  324.         {
  325.             case ACTIVEWINDOW:
  326.             {
  327.                 if (SCREEN==NULL) SetColours();
  328.                 break;
  329.             }
  330.     
  331.             case INACTIVEWINDOW:
  332.             {
  333.                 if (SCREEN==NULL) SetOldColours();
  334.                 break;
  335.             }
  336.     
  337.             case CLOSEWINDOW:
  338.             {   
  339.                 if (MyReq("Do really want to quit ?"," Yes ","Oh no")==TRUE)
  340.                 {
  341.                     FreeRaster(mem,640,256);
  342.                     CloseStuff();
  343.                 }        
  344.                 break;
  345.             }
  346.             
  347.             case NEWSIZE:
  348.             {
  349.                 refresh=1;
  350.                 goto aufbau;            
  351.                 break;
  352.             }
  353.     
  354.             case GADGETDOWN:
  355.             {
  356.                 while(Gadget1.Activation & SELECTED || Gadget1.Flags & SELECTED)
  357.                 {
  358.                     volume=Gadget1SInfo.VertPot;
  359.                     volume=((65535-volume)*99)/65535;
  360.                     SingleParameterSend(3,0,volume);
  361.                     NumBox(20,85,130,"Volume    :",volume+1);
  362.                 }
  363.                 break;
  364.             }
  365.     
  366.             case GADGETUP:
  367.             {
  368.                 volume=Gadget1SInfo.VertPot;
  369.                 volume=((65535-volume)*99)/65535;
  370.                 SingleParameterSend(3,0,volume);
  371.                 NumBox(20,85,130,"Volume    :",volume+1);
  372.                 break;
  373.             }    
  374.     
  375.             case MOUSEBUTTONS:
  376.             {
  377.                 
  378.                 if (code==MENUDOWN)
  379.                 {
  380.                 /*    EncodeSingle(nr);
  381.                     SetAPen(win->RPort,0);
  382.                     SetBPen(win->RPort,0);    
  383.                     SetOPen(win->RPort,0);
  384.                     RectFill(win->RPort,10,11,616,250);
  385.                     Gadget1SInfo.VertPot=oldvol;
  386.                     RefreshGadgets(&Gadget1,win,NULL); 
  387.                     FreeRaster(mem,640,256);
  388.                     multi=0;
  389.                     Display();
  390.                     return();    */
  391.                 }        
  392.     
  393.                 if (code==SELECTDOWN)
  394.                 {
  395.                     if (Check(x,y,567,614,13,23))                    /* OK */
  396.                     {
  397.                         EncodeSingle(nr);
  398.                         SetAPen(win->RPort,0);
  399.                         SetBPen(win->RPort,0);    
  400.                         SetOPen(win->RPort,0);
  401.                         RectFill(win->RPort,10,11,616,250);
  402.                         Gadget1SInfo.VertPot=oldvol;
  403.                         RefreshGadgets(&Gadget1,win,NULL); 
  404.                         FreeRaster(mem,640,256);
  405.                         multi=0;
  406.                         Display();
  407.                         return();                    
  408.                     }        
  409.     
  410.                     if (Check(x,y,548,606,27,37))                    /* Undo */
  411.                     {
  412.                         int j;
  413.     
  414.                         if (MyReq("Are you shure ?"," Yes ","Oh no"))
  415.                         {
  416.                             for (j=0;j<=87;j++) s[nr/32][nr%32][j]=f[j];
  417.                             DecodeSingle(nr);
  418.                             envlevel[0]++; EnvDisplay();
  419.                             envlevel[0]--; EnvDisplay();
  420.                             goto aufbau;
  421.                         }
  422.                     }        
  423.     
  424.                     if (Check(x,y,548,606,42,52))                    /* Print */
  425.                     {
  426.                         PrintSingle(nr);
  427.                         break;
  428.                     }        
  429.     
  430.                     if (Check(x,y,548,606,57,67))                    /* Rename */
  431.                     {
  432.                         char st[20];
  433.                         int i;
  434.     
  435.                         strstruct.titlebar        =NULL;
  436.                         strstruct.Window        =win;            
  437.                         strstruct.visiblesize    =11;
  438.                         strstruct.versionnumber    =REQVERSION;
  439.                         strstruct.flags            =NULL;                    
  440.                         strstruct.rfu1            =NULL;
  441.                         strstruct.rfu2            =NULL;
  442.                         strstruct.rfu3            =NULL;
  443.     
  444.                         for (i=0;i<=9;i++) st[i]=s[nr/32][nr%32][i];
  445.                         for (i=9;i>=0;i--) 
  446.                         {
  447.                             if (st[i] == 32) st[i]=0;
  448.                             else break;
  449.                         }
  450.                         st[10]='\0';
  451.                         strstruct.stringbuffer    =&st[0];    
  452.                         strstruct.stringsize    =11;
  453.     
  454.                         if (NewGetString(&strstruct))
  455.                         {
  456.                             int f;
  457.     
  458.                             for (f=0,i=0;i<=9;i++) 
  459.                             {
  460.                                 if (f == 0 && st[i] != 0) { s[nr/32][nr%32][i]=st[i];  }
  461.                                             else {f=1; s[nr/32][nr%32][i]=32;    }            
  462.                             }
  463.                             EncodeSingle(nr);
  464.                         }
  465.                         goto aufbau;    
  466.                     }        
  467.     
  468.                     if (Check(x,y,548,606,72,82))                /* Initialize */
  469.                     {
  470.                         int j;
  471.     
  472.                         if (MyReq("Are you shure ?"," Yes ","Oh no"))
  473.                         {
  474.                             for (j=0;j<=87;j++) s[nr/32][nr%32][j]=initsing[j];
  475.                             DecodeSingle(nr);
  476.                             envlevel[0]++; EnvDisplay();
  477.                             envlevel[0]--; EnvDisplay();
  478.                             goto aufbau;
  479.                         }
  480.                     }    
  481.     
  482.                     if (Check(x,y,548,606,87,97))                /* Patch testen */
  483.                     {                
  484.                         TestSound(MASTERCHANNEL);
  485.                         goto aufbau;
  486.                     }    
  487.     
  488.     
  489.                     if (Check(x,y,483,541,27,37))                /* Load */
  490.                     {
  491.                         LoadSound(nr+1000);
  492.                         DecodeSingle(nr);
  493.                         TransmitSingleSound(nr);
  494.     
  495.                         goto aufbau;
  496.                     }
  497.     
  498.                     if (Check(x,y,483,541,42,52))                /* Save */
  499.                     {
  500.                         SaveSound(nr);
  501.     
  502.                         goto aufbau;
  503.                     }
  504.     
  505.                     if (Check(x,y,483,541,57,67))                /* P-Copy */
  506.                     {
  507.                         int mx,my; 
  508.     
  509.                         Make_SingleWindow("Select patch to copy to...");
  510.                         DisplaySingleEdWindow();
  511.                 loop:    WaitPort(win3->UserPort);
  512.                         mesg=(struct IntuiMessage *) GetMsg(win3->UserPort);
  513.                         mx=mesg->MouseX;
  514.                         my=mesg->MouseY;
  515.     
  516.                         if (mesg->Class == CLOSEWINDOW)
  517.                         {
  518.                             ReplyMsg((struct Message *)mesg);
  519.                             CloseWindow(win3);
  520.                             goto start;
  521.                         }
  522.     
  523.                         if (mesg->Class == MOUSEBUTTONS && mesg->Code == SELECTDOWN)
  524.                         {
  525.                             if (mx>15 && mx<415 && my>15 && my<175)
  526.                             {
  527.                                 int num;
  528.     
  529.                                 if (mx>15 && mx<215)    num=(my-15)/10*2+((mx<115)?0:1);
  530.                                 if (mx>215 && mx<415)    num=32+(my-15)/10*2+((mx<315)?0:1);
  531.                                 ReplyMsg((struct Message *)mesg);
  532.                                 CloseWindow(win3);
  533.                                 EncodeSingle(nr);
  534.                                 for (i=0;i<=87;i++) s[num/32][num%32][i]=s[nr/32][nr%32][i];
  535.                                 TransmitSingleSound(num);
  536.                                 ProgChange(nr);    
  537.                                 goto Loop;
  538.                             }
  539.                             else
  540.                             {
  541.                                 ReplyMsg((struct Message *)mesg);
  542.                                 goto loop;
  543.                             }    
  544.                         }
  545.                         ReplyMsg((struct Message *)mesg);
  546.                         goto loop;
  547.                         goto aufbau;
  548.                     }
  549.     
  550.                     if (Check(x,y,483,541,72,82))                        /* P-Swap */
  551.                     {
  552.                         int mx,my; 
  553.     
  554.                         Make_SingleWindow("Select patch to swap with...");
  555.                         DisplaySingleEdWindow();
  556.                 loop1:    WaitPort(win3->UserPort);
  557.                         mesg=(struct IntuiMessage *) GetMsg(win3->UserPort);
  558.                         mx=mesg->MouseX;
  559.                         my=mesg->MouseY;
  560.     
  561.                         if (mesg->Class == CLOSEWINDOW)
  562.                         {
  563.                             ReplyMsg((struct Message *)mesg);
  564.                             CloseWindow(win3);
  565.                             goto start;
  566.                         }
  567.     
  568.                         if (mesg->Class == MOUSEBUTTONS && mesg->Code == SELECTDOWN)
  569.                         {
  570.                             if (mx>15 && mx<415 && my>15 && my<175)
  571.                             {
  572.                                 int num;
  573.     
  574.                                 if (mx>15 && mx<215)    num=(my-15)/10*2+((mx<115)?0:1);
  575.                                 if (mx>215 && mx<415)    num=32+(my-15)/10*2+((mx<315)?0:1);
  576.                                 ReplyMsg((struct Message *)mesg);
  577.                                 CloseWindow(win3);
  578.                                 EncodeSingle(nr);
  579.                                 for (i=0;i<=87;i++)
  580.                                 {
  581.                                         int h;
  582.                                         h=s[num/32][num%32][i];
  583.                                         s[num/32][num%32][i]=s[nr/32][nr%32][i];
  584.                                         s[nr/32][nr%32][i]=h;
  585.                                 }
  586.                                 TransmitSingleSound(nr);
  587.                                 TransmitSingleSound(num);
  588.                                 ProgChange(nr);
  589.                                 DecodeSingle(nr);    
  590.                                 goto aufbau;
  591.                             }
  592.                             else
  593.                             {
  594.                                 ReplyMsg((struct Message *)mesg);
  595.                                 goto loop1;
  596.                             }    
  597.                         }
  598.                         ReplyMsg((struct Message *)mesg);
  599.                         goto loop1;
  600.                         goto aufbau;
  601.                     }
  602.     
  603.                     if (Check(x,y,483,541,87,97))                /* Oscillators */
  604.                     {
  605.                         Oscillators();
  606.                         goto start;
  607.                     }
  608.     
  609.                     if (Check(x,y,260,455,20,75))                /* Hüllkurve editieren */
  610.                     {
  611.                         EnvEdit(nr);
  612.                         goto aufbau;
  613.                     }    
  614.         
  615.                     for (i=0;i<=2*(sources+1)-1;i++)
  616.                     {
  617.                         if (Check(x,y,150*i+20,150*i+53,110,120))
  618.                         {
  619.                             mute[i]=mute[i]==1 ? 0 : 1;
  620.                             envlevel[i]++;EnvDisplay();    
  621.                             envlevel[i]--;EnvDisplay();    
  622.                             DisplaySingleLine(i);
  623.                             EncodeSingle(nr);
  624.                             goto Loop;
  625.                         }                    
  626.     
  627.                         if (Check(x,y,150*i+53,150*i+86,110,120))
  628.                         {
  629.                             if (keytrack[i]==1) keytrack[i]=0;
  630.                             else
  631.                             {    
  632.                                 keytrack[i]=1;
  633.                                 if (coarse[i]<60 || coarse[i]>108) coarse[i]=84;
  634.                             }
  635.                             SingleParameterSend(31,i,keytrack[i]);
  636.                             DisplaySingleLine(i);
  637.                             goto Loop;
  638.                         }                    
  639.     
  640.                         if (Check(x,y,150*i+86,150*i+119,110,120))
  641.                         {
  642.                             vibabend[i]=vibabend[i]==1 ? 0 : 1;
  643.                             SingleParameterSend(32,i,vibabend[i]);
  644.                             DisplaySingleLine(i);
  645.                             goto Loop;
  646.                         }                    
  647.     
  648.                         if (Check(x,y,150*i+119,150*i+152,110,120))
  649.                         {
  650.                             prsonfreq[i]=prsonfreq[i]==1 ? 0 : 1;
  651.                             SingleParameterSend(33,i,prsonfreq[i]);
  652.                             DisplaySingleLine(i);
  653.                             goto Loop;
  654.                         }                    
  655.     
  656.                         if (Check(x,y,150*i+20,150*i+170,150,160))
  657.                         {
  658.                             SingleProp(wave[i],255,0,i);
  659.                             DisplaySingleLine(i);
  660.                             goto Loop;
  661.                         }
  662.     
  663.                         if (Check(x,y,150*i+20,150*i+110,140,150))
  664.                         {
  665.                             SingleProp(envlevel[i],100,1,i);
  666.                             DisplaySingleLine(i);
  667.                             EnvDisplay();
  668.                             goto Loop;
  669.                         }
  670.     
  671.                         if (Check(x,y,150*i+10,150*i+40,175,185))
  672.                         {
  673.                             SingleProp(envdelay[i],100,2,i);
  674.                             DisplaySingleLine(i);
  675.                             EnvDisplay();
  676.                             goto Loop;
  677.                         }
  678.     
  679.                         if (Check(x,y,150*i+40,150*i+70,175,185))
  680.                         {
  681.                             SingleProp(envattack[i],100,3,i);
  682.                             DisplaySingleLine(i);
  683.                             EnvDisplay();
  684.                             goto Loop;
  685.                         }
  686.     
  687.                         if (Check(x,y,150*i+70,150*i+100,175,185))
  688.                         {
  689.                             SingleProp(envdecay[i],100,4,i);
  690.                             EnvDisplay();
  691.                             DisplaySingleLine(i);
  692.                             goto Loop;
  693.                         }
  694.     
  695.                         if (Check(x,y,150*i+100,150*i+130,175,185))
  696.                         {
  697.                             SingleProp(envsustain[i],100,5,i);
  698.                             EnvDisplay();
  699.                             DisplaySingleLine(i);
  700.                             goto Loop;
  701.                         }
  702.     
  703.                         if (Check(x,y,150*i+130,150*i+160,175,185))
  704.                         {
  705.                             SingleProp(envrelease[i],100,6,i);
  706.                             EnvDisplay();
  707.                             DisplaySingleLine(i);
  708.                             goto Loop;
  709.                         }
  710.     
  711.                         if (Check(x,y,150*i+20,150*i+155,190,200))
  712.                         {
  713.                             SingleProp(levelmodvel[i],100,7,i);
  714.                             DisplaySingleLine(i);
  715.                             goto Loop;
  716.                         }
  717.     
  718.                         if (Check(x,y,150*i+20,150*i+155,200,210))
  719.                         {
  720.                             SingleProp(levelmodprs[i],100,8,i);
  721.                             DisplaySingleLine(i);
  722.                             goto Loop;
  723.                         }
  724.     
  725.                         if (Check(x,y,150*i+20,150*i+155,210,220))
  726.                         {
  727.                             SingleProp(levelmodks[i],100,9,i);
  728.                             DisplaySingleLine(i);
  729.                             goto Loop;
  730.                         }
  731.     
  732.                         if (Check(x,y,150*i+20,150*i+155,220,230))
  733.                         {
  734.                             SingleProp(timemodvel[i],100,10,i);
  735.                             DisplaySingleLine(i);
  736.                             goto Loop;
  737.                         }
  738.     
  739.                         if (Check(x,y,150*i+20,150*i+155,230,240))
  740.                         {
  741.                             SingleProp(timemodks[i],100,11,i);
  742.                             DisplaySingleLine(i);
  743.                             goto Loop;
  744.                         }
  745.     
  746.                         if (Check(x,y,150*i+20,150*i+155,240,250))
  747.                         {
  748.                             SingleProp(freqksfreq[i],100,12,i);
  749.                             DisplaySingleLine(i);
  750.                             goto Loop;
  751.                         }
  752.     
  753.                         if (Check(x,y,150*i+20,150*i+110,120,130))
  754.                         {
  755.                             if (keytrack[i]==1) SingleProp(coarse[i]-60,48,13,i);
  756.                             if (keytrack[i]==0) SingleProp(coarse[i],127,15,i);
  757.                             DisplaySingleLine(i);
  758.                             goto Loop;
  759.                         }
  760.     
  761.                         if (Check(x,y,150*i+20,150*i+110,130,140))
  762.                         {
  763.                             SingleProp(fine[i],100,14,i);
  764.                             DisplaySingleLine(i);
  765.                             goto Loop;
  766.                         }
  767.     
  768.                         if (Check(x,y,150*i+110,150*i+155,120,150))
  769.                         {
  770.                             velcurve[i]++;
  771.                             if (velcurve[i]>7) velcurve[i]=0;
  772.                             SingleParameterSend(47,i,velcurve[i]);
  773.                             DisplaySingleLine(i);
  774.                             goto Loop;
  775.                         }
  776.                     }
  777.     
  778.                     /***********/
  779.                     /* Vibrato */                    
  780.                     /***********/    
  781.     
  782.                     if (Check(x,y,20,150,20,30))
  783.                     {
  784.                         lfoshape++;
  785.                         if (lfoshape>3) lfoshape=0;
  786.                         SingleParameterSend(17,0,lfoshape);
  787.                         DisplaySingleLine(4);
  788.                         goto Loop;
  789.                     }
  790.     
  791.                     if (Check(x,y,20,150,30,40))
  792.                     {
  793.                         SingleProp(lfospeed,100,21,0);
  794.                         DisplaySingleLine(4);
  795.                         goto Loop;
  796.                     }
  797.     
  798.                     if (Check(x,y,20,150,40,50))
  799.                     {
  800.                         SingleProp(vibdepth,100,22,0);
  801.                         DisplaySingleLine(4);
  802.                         goto Loop;
  803.                     }
  804.     
  805.                     if (Check(x,y,20,150,50,60))
  806.                     {
  807.                         SingleProp(vibpres,100,23,0);
  808.                         DisplaySingleLine(4);
  809.                         goto Loop;
  810.                     }
  811.     
  812.                     if (Check(x,y,20,150,60,70))
  813.                     {
  814.                         if (vibwheel==0) vibwheel=1;
  815.                                     else vibwheel=0;
  816.                         SingleParameterSend(19,0,vibwheel);
  817.                         DisplaySingleLine(4);
  818.                         goto Loop;
  819.                     }
  820.     
  821.                     /************/
  822.                     /* Auto-Bend*/                    
  823.                     /************/    
  824.     
  825.                     if (Check(x,y,150,260,20,30))
  826.                     {
  827.                         SingleProp(autodepth,100,30,0);
  828.                         DisplaySingleLine(4);
  829.                         goto Loop;
  830.                     }
  831.     
  832.                     if (Check(x,y,150,260,30,40))
  833.                     {
  834.                         SingleProp(autotime,100,31,0);
  835.                         DisplaySingleLine(4);
  836.                         goto Loop;
  837.                     }
  838.     
  839.                     if (Check(x,y,150,260,40,50))
  840.                     {
  841.                         SingleProp(autobendvel,100,32,0);
  842.                         DisplaySingleLine(4);
  843.                         goto Loop;
  844.                     }
  845.     
  846.                     if (Check(x,y,150,260,50,60))
  847.                     {
  848.                         SingleProp(autobendks,100,33,0);
  849.                         DisplaySingleLine(4);
  850.                         goto Loop;
  851.                     }
  852.     
  853.                     if (Check(x,y,150,260,60,70))
  854.                     {
  855.                         SingleProp(prsfreq,100,41,0);
  856.                         DisplaySingleLine(4);
  857.                         goto Loop;
  858.                     }
  859.     
  860.                     /*************/
  861.                     /* Pitchbend */                    
  862.                     /*************/    
  863.     
  864.                     if (Check(x,y,20,150,75,85))
  865.                     {
  866.                         SingleProp(pitchbend,12,40,0);
  867.                         DisplaySingleLine(4);
  868.                         goto Loop;
  869.                     }
  870.     
  871.                     if (Check(x,y,20,150,85,95))
  872.                     {
  873.                         SingleProp(volume,99,42,0);
  874.                         NumBox(20,85,130,"Volume    :",volume+1);
  875.                         Gadget1SInfo.VertPot=65535-volume*656;
  876.                         RefreshGadgets(&Gadget1,win,NULL); 
  877.                         goto Loop;
  878.                     }    
  879.     
  880.                     /**************/
  881.                     /* Modulation */                    
  882.                     /**************/    
  883.     
  884.                     if (Check(x,y,150,260,75,85))
  885.                     {
  886.                         ams1++;
  887.                         if (ams1>2) ams1=0;
  888.                         SingleParameterSend(36,0,ams1);
  889.                         DisplaySingleLine(4);
  890.                         goto Loop;
  891.                     }
  892.     
  893.                     if (Check(x,y,150,260,85,95))
  894.                     {
  895.                         ams2++;
  896.                         if (ams2>2) ams2=0;
  897.                         SingleParameterSend(37,0,ams2);
  898.                         DisplaySingleLine(4);
  899.                         goto Loop;
  900.                     }
  901.     
  902.                     /*************/
  903.                     /* Poly-Mode */                    
  904.                     /*************/    
  905.     
  906.                     if (Check(x,y,260,390,75,85))
  907.                     {
  908.                         polymode++;
  909.                         if (polymode>2) polymode=0;
  910.                         SingleParameterSend(27,0,polymode);
  911.                         DisplaySingleLine(4);
  912.                         goto Loop;
  913.                     }
  914.     
  915.                     if (Check(x,y,260,390,85,95))
  916.                     {
  917.                         sources++;
  918.                         if (sources>1) sources=0;
  919.                         oldenvlevel[0]=-1;
  920.                         EnvDisplay();
  921.                         for (i=2;i<=4;i++) DisplaySingleLine(i);
  922.                         SingleParameterSend(14,0,sources);
  923.                         EnvDisplay();
  924.                         goto Loop;
  925.                     }
  926.                         
  927.                     if (Check(x,y,390,455,75,95))
  928.                     {
  929.                         kscurve++;
  930.                         if (kscurve>4) kscurve=0;
  931.                         SingleParameterSend(26,0,kscurve);
  932.                         DisplaySingleLine(4);
  933.                         goto Loop;
  934.                     }
  935.                         
  936.                 } /* of SELECTDOWN */
  937.             } /* of case MOUSEBUTTONS */    
  938.              
  939.             default: break;    
  940.         }
  941.     }
  942.     goto Loop;
  943. }
  944.  
  945. /**********************************************************************************/
  946. /***                                                                            ***/
  947. /**********************************************************************************/
  948.  
  949. void SingleProp(int current,int max,int flag,int nr)
  950. {
  951.     struct Gadget     gad;
  952.     struct PropInfo prop;
  953.     char str[80];    
  954.     long val;
  955.     
  956.     Make_PropWindow(current != 0 ? 120*current/max+6 : 12);
  957.     
  958.     prop.Flags=AUTOKNOB+FREEHORIZ;
  959.     prop.HorizPot=0;
  960.     prop.VertPot=-1;
  961.     prop.HorizBody=65535/max;
  962.     prop.VertBody=-1;    
  963.     
  964.     gad.NextGadget=NULL;
  965.     gad.LeftEdge=8;
  966.     gad.TopEdge=12;
  967.     gad.Width=120;
  968.     gad.Height=10;
  969.     gad.Flags=GADGHBOX;
  970.     gad.Activation=RELVERIFY+GADGIMMEDIATE;
  971.     gad.GadgetType=PROPGADGET;
  972.     gad.GadgetRender=(APTR)&Image1;
  973.     gad.SelectRender=NULL;
  974.     gad.GadgetText=NULL;
  975.     gad.MutualExclude=NULL;
  976.     gad.SpecialInfo=(APTR)∝
  977.     gad.GadgetID=0;
  978.     gad.UserData=0;
  979.  
  980.     prop.HorizPot=prop.HorizBody*current;
  981.     AddGadget(win4,&gad,-1); 
  982.     RefreshGadgets(&gad,win4,NULL); 
  983.  
  984.     str[0]=0;
  985.     if (flag==1)  strcpy(str,"Level");
  986.     if (flag==2)  strcpy(str,"Delay");
  987.     if (flag==3)  strcpy(str,"Attack");
  988.     if (flag==4)  strcpy(str,"Decay");
  989.     if (flag==5)  strcpy(str,"Sustain");
  990.     if (flag==6)  strcpy(str,"Release");
  991.     if (flag==7)  strcpy(str,"Level>Vel");
  992.     if (flag==8)  strcpy(str,"Level>Prs");
  993.     if (flag==9)  strcpy(str,"Level>KS ");
  994.     if (flag==10) strcpy(str,"Time>Vel ");
  995.     if (flag==11) strcpy(str,"Time>KS  ");
  996.     if (flag==12) strcpy(str,"KS>Freq  ");
  997.     if (flag==13) strcpy(str,"Coarse   ");
  998.     if (flag==14) strcpy(str,"Fine     ");
  999.     if (flag==15) strcpy(str,"Fixed key");
  1000.     if (flag==21) strcpy(str,"Vib-Speed");
  1001.     if (flag==22) strcpy(str,"Vib-Depth");
  1002.     if (flag==23) strcpy(str,"Prs>Depth");
  1003.     if (flag==30) strcpy(str,"Depth");
  1004.     if (flag==31) strcpy(str,"Time");
  1005.     if (flag==32) strcpy(str,"Vel>Depth");
  1006.     if (flag==33) strcpy(str,"KS>Time");
  1007.     if (flag==40) strcpy(str,"Pitchbend");
  1008.     if (flag==41) strcpy(str,"Prs>Freq");
  1009.     if (flag==42) strcpy(str,"Volume");
  1010.  
  1011.     Print(win4,10,9,&str[0]);
  1012.  
  1013.     val=prop.HorizPot/prop.HorizBody;
  1014.     DisplaySingleValue(flag,val);
  1015.  
  1016.     if (flag>=1 && flag<=6)    EnvDisplay();
  1017.  
  1018. loop:    WaitPort(win4->UserPort);
  1019.         mesg=(struct IntuiMessage *) GetMsg(win4->UserPort);
  1020.  
  1021.         if (mesg->Class == GADGETDOWN)
  1022.         {
  1023.             ReplyMsg((struct Message *)mesg);
  1024.             while(gad.Flags & SELECTED) 
  1025.             {
  1026.                 val=prop.HorizPot/prop.HorizBody;
  1027.                 ReturnValue(nr,flag,val);
  1028.                 DisplaySingleValue(flag,val);
  1029.                 if (flag>=1 && flag<=6) EnvDisplay();
  1030.             }
  1031.             goto loop;
  1032.         }
  1033.  
  1034.         if (mesg->Class == GADGETUP)
  1035.         {
  1036.             ReplyMsg((struct Message *)mesg);
  1037.             val=prop.HorizPot/prop.HorizBody;
  1038.             ReturnValue(nr,flag,val);
  1039.             DisplaySingleValue(flag,val);
  1040.             if (flag>=1 && flag<=6) EnvDisplay();
  1041.             goto loop;
  1042.         }
  1043.  
  1044.         if (mesg->Class == MOUSEBUTTONS && mesg->Code==MENUDOWN)
  1045.         {
  1046.             ReplyMsg((struct Message *)mesg);
  1047.             val=prop.HorizPot/prop.HorizBody;
  1048.  
  1049.             ReturnValue(nr,flag,val);
  1050.             if (flag>=1 && flag<=6) EnvDisplay();
  1051.             CloseWindow(win4);
  1052.             return();
  1053.         }
  1054.  
  1055.         ReplyMsg((struct Message *)mesg);
  1056.         goto loop;
  1057. }
  1058.  
  1059. /**********************************************************************************/
  1060. /***                                                                            ***/
  1061. /**********************************************************************************/
  1062.  
  1063. void DisplaySingleValue(const int flag,const long val)
  1064. {
  1065.     char string[80];
  1066.  
  1067.     string[0]=0;
  1068.     if (flag==0)                 { sprintf(string,"%-16s",WaveName[val]); goto Print; }
  1069.     if (flag>=1 && flag<=6)        { sprintf(string,"%3ld ",val);        goto Print; }
  1070.     if (flag>=7 && flag<=12)    { sprintf(string,"%3ld ",val-50);    goto Print; }
  1071.     if (flag==13)                { sprintf(string,"%3ld ",val-24);    goto Print; }
  1072.     if (flag==14)                { sprintf(string,"%3ld ",val-50);    goto Print; }
  1073.     if (flag==15)                  { sprintf(string,"%2s%2ld",ToneName[val%12],(val/12)-4); goto Print; }
  1074.     if (flag==21)                { sprintf(string,"%3ld ",val);        goto Print; }
  1075.     if (flag>=22 && flag<=23)    { sprintf(string,"%3ld ",val-50);    goto Print; }
  1076.     if (flag==30)                { sprintf(string,"%3ld ",val-50);    goto Print; }
  1077.     if (flag==31)                { sprintf(string,"%3ld ",val);        goto Print; }
  1078.     if (flag==32)                { sprintf(string,"%3ld ",val-50);    goto Print; }
  1079.     if (flag==33)                { sprintf(string,"%3ld ",val-50);    goto Print; }
  1080.     if (flag==40)                { sprintf(string,"%3ld ",val);        goto Print; }
  1081.     if (flag==41)                { sprintf(string,"%3ld ",val-50);     goto Print; }
  1082.     if (flag==42)                { sprintf(string,"%3ld ",val+1);    goto Print; }
  1083.  
  1084. Print: ;
  1085.     if (flag==0)    Print(win4,5,9,string);
  1086.     if (flag==0)
  1087.     {
  1088.         sprintf(string,"%3ld",val+1);
  1089.         Print(win4,5,29,string);
  1090.     }
  1091.     if (flag != 0)    Print(win4,95,9,string);
  1092. }
  1093.  
  1094. /**********************************************************************************/
  1095. /***                                                                            ***/
  1096. /**********************************************************************************/
  1097.  
  1098. void ReturnValue(const int nr,const int flag,const long val)
  1099. {
  1100.     if (flag==0)     { wave[nr]            =val;     goto Send; }
  1101.     if (flag==1)     { envlevel[nr]        =val;     goto Send; }
  1102.     if (flag==2)     { envdelay[nr]        =val;     goto Send; }
  1103.     if (flag==3)     { envattack[nr]        =val;     goto Send; }
  1104.     if (flag==4)     { envdecay[nr]        =val;     goto Send; }
  1105.     if (flag==5)     { envsustain[nr]    =val;     goto Send; }
  1106.     if (flag==6)     { envrelease[nr]    =val;     goto Send; }
  1107.     if (flag==7)     { levelmodvel[nr]    =val;     goto Send; }
  1108.     if (flag==8)     { levelmodprs[nr]    =val;     goto Send; }
  1109.     if (flag==9)     { levelmodks[nr]    =val;     goto Send; }
  1110.     if (flag==10)    { timemodvel[nr]    =val;     goto Send; }
  1111.     if (flag==11)    { timemodks[nr]        =val;     goto Send; }
  1112.     if (flag==12)    { freqksfreq[nr]    =val;     goto Send; }
  1113.     if (flag==13)   { coarse[nr]       =val+60; goto Send; }
  1114.     if (flag==14)    { fine[nr]            =val;     goto Send; }
  1115.     if (flag==15)    { coarse[nr]        =val;     goto Send; }
  1116.     if (flag==21)    { lfospeed            =val;     goto Send; }
  1117.     if (flag==22)    { vibdepth            =val;     goto Send; }
  1118.     if (flag==23)    { vibpres            =val;     goto Send; }
  1119.     if (flag==30)    { autodepth            =val;     goto Send; }
  1120.     if (flag==31)    { autotime            =val;     goto Send; }
  1121.     if (flag==32)    { autobendvel        =val;     goto Send; }
  1122.     if (flag==33)    { autobendks        =val;     goto Send; }
  1123.     if (flag==40)    { pitchbend            =val;     goto Send; }
  1124.     if (flag==41)    { prsfreq            =val;     goto Send; }
  1125.     if (flag==42)    { volume            =val;    goto Send; }    
  1126.  
  1127. Send: ;
  1128.     if (flag==0)     { SingleParameterSend(35,nr,wave[nr]);        return(); }
  1129.     if (flag==1)     { SingleParameterSend(41,nr,envlevel[nr]);    return(); }
  1130.     if (flag==2)     { SingleParameterSend(42,nr,envdelay[nr]);     return(); }
  1131.     if (flag==3)     { SingleParameterSend(43,nr,envattack[nr]);    return(); }
  1132.     if (flag==4)     { SingleParameterSend(44,nr,envdecay[nr]);    return(); }
  1133.     if (flag==5)     { SingleParameterSend(45,nr,envsustain[nr]);    return(); }
  1134.     if (flag==6)     { SingleParameterSend(46,nr,envrelease[nr]);    return(); }
  1135.     if (flag==7)     { SingleParameterSend(48,nr,levelmodvel[nr]);    return(); }
  1136.     if (flag==8)     { SingleParameterSend(49,nr,levelmodprs[nr]);    return(); }
  1137.     if (flag==9)     { SingleParameterSend(50,nr,levelmodks[nr]);    return(); }
  1138.     if (flag==10)    { SingleParameterSend(51,nr,timemodvel[nr]);    return(); }
  1139.     if (flag==11)    { SingleParameterSend(52,nr,timemodks[nr]);    return(); }
  1140.     if (flag==12)    { SingleParameterSend(34,nr,freqksfreq[nr]);    return(); }
  1141.     if (flag==13)   { SingleParameterSend(28,nr,coarse[nr]);        return(); }
  1142.     if (flag==14)    { SingleParameterSend(30,nr,fine[nr]);        return(); }
  1143.     if (flag==15)    { SingleParameterSend(29,nr,coarse[nr]);        return(); }
  1144.     if (flag==21)    { SingleParameterSend(16,0,lfospeed);            return(); }
  1145.     if (flag==22)    { SingleParameterSend(15,0,vibdepth);            return(); }
  1146.     if (flag==23)    { SingleParameterSend(18,0,vibpres);            return(); }
  1147.     if (flag==30)    { SingleParameterSend(20,0,autodepth);        return(); }
  1148.     if (flag==31)    { SingleParameterSend(21,0,autotime);            return(); }
  1149.     if (flag==32)    { SingleParameterSend(22,0,autobendvel);        return(); }
  1150.     if (flag==33)    { SingleParameterSend(23,0,autobendks);        return(); }
  1151.     if (flag==40)    { SingleParameterSend(25,0,pitchbend);        return(); }
  1152.     if (flag==41)    { SingleParameterSend(24,0,prsfreq);            return(); }
  1153.     if (flag==42)    { SingleParameterSend(3,0,volume);            return(); }
  1154. }
  1155.  
  1156. /**********************************************************************************/
  1157. /***                                                                            ***/
  1158. /**********************************************************************************/
  1159.  
  1160. void EncodeSingle(const int nr)
  1161. {
  1162.     int i,sum;
  1163.  
  1164.     if (nr>128)                        /* user cancel */
  1165.     {
  1166.         for (i=0;i<=87;i++) s[(nr-128)/32][(nr-128)%32][i]=f[i];
  1167.         TransmitSingleSound(nr-128);
  1168.         return();
  1169.     }
  1170.  
  1171.     RefreshGadgets(&Gadget1,win,NULL); 
  1172.     volume=99-Gadget1SInfo.VertPot/656;
  1173.     volume=volume >99 ? 99 : volume;
  1174.     for (i=0;i<=9;i++) if(s[nr/32][nr%32][i]==0) s[nr/32][nr%32][i]=32;
  1175.  
  1176.     s[nr/32][nr%32][10]=volume;
  1177.     s[nr/32][nr%32][11]=polymode+sources*4+ams1*8+ams2*32;
  1178.     s[nr/32][nr%32][12]=prsfreq;
  1179.     s[nr/32][nr%32][13]=vibdepth;
  1180.     s[nr/32][nr%32][14]=vibpres;
  1181.     s[nr/32][nr%32][15]=pitchbend;
  1182.     s[nr/32][nr%32][16]=lfospeed;
  1183.     s[nr/32][nr%32][17]=lfoshape+4*kscurve+32*vibwheel;
  1184.     s[nr/32][nr%32][18]=autodepth;
  1185.     s[nr/32][nr%32][19]=autotime;
  1186.     s[nr/32][nr%32][20]=autobendvel;
  1187.     s[nr/32][nr%32][21]=autobendks;
  1188.     s[nr/32][nr%32][22]=mute[0]+mute[1]*2+mute[2]*4+mute[3]*8;
  1189.  
  1190.     for (i=0;i<=3;i++)
  1191.     {
  1192.         s[nr/32][nr%32][23+i]= fine[i]%128;
  1193.         s[nr/32][nr%32][27+i]= coarse[i]%128;
  1194.         s[nr/32][nr%32][31+i]= wave[i]%128;
  1195.         s[nr/32][nr%32][35+i]=((wave[i]/128)+keytrack[i]*2+vibabend[i]*4+prsonfreq[i]*8+velcurve[i]*16)&127;
  1196.  
  1197.         s[nr/32][nr%32][39+i]= envlevel[i];
  1198.         s[nr/32][nr%32][43+i]= envdelay[i];
  1199.         s[nr/32][nr%32][47+i]= envattack[i];
  1200.         s[nr/32][nr%32][51+i]= envdecay[i];
  1201.         s[nr/32][nr%32][55+i]= envsustain[i];
  1202.         s[nr/32][nr%32][59+i]= envrelease[i];
  1203.  
  1204.         s[nr/32][nr%32][63+i]= levelmodvel[i];
  1205.         s[nr/32][nr%32][67+i]= levelmodprs[i];
  1206.         s[nr/32][nr%32][71+i]= levelmodks[i];
  1207.         s[nr/32][nr%32][75+i]= timemodvel[i];
  1208.         s[nr/32][nr%32][79+i]= timemodks[i];
  1209.         s[nr/32][nr%32][83+i]= freqksfreq[i];
  1210.     }
  1211.  
  1212.     sum=0xa5;                        /* Prüfsumme berechnen */
  1213.     for (i=0;i<=86;i++) sum=(sum+s[nr/32][nr%32][i]) & 127;
  1214.     s[nr/32][nr%32][87]=sum;
  1215.  
  1216.     TransmitSingleSound(nr);
  1217. }
  1218.  
  1219. /**********************************************************************************/
  1220. /***                                                                            ***/
  1221. /**********************************************************************************/
  1222.  
  1223. void NumBox(int x,int y,int wide,char *s,int val)
  1224. {
  1225.     char string[10];
  1226.  
  1227.     MakeBox(win,x,y,x+wide,y+10);
  1228.     sprintf(string,"%3d",val);
  1229.     Print(win,x+wide-30,y+8,string);
  1230.     Print(win,x+4,y+8,s);
  1231. }
  1232.  
  1233. /**********************************************************************************/
  1234. /***                                                                            ***/
  1235. /**********************************************************************************/
  1236.  
  1237. int Check(int x,int y,int xmin,int xmax,int ymin,int ymax)
  1238. {
  1239.     if (x>xmin && x<xmax && y>ymin && y<ymax) return(1);
  1240.                                         else  return(0);
  1241. }
  1242.  
  1243. /**********************************************************************************/
  1244. /***                                                                            ***/
  1245. /**********************************************************************************/
  1246.  
  1247. void DisplaySingleLine(int pos)
  1248. {
  1249.     char str[80];
  1250.     int i;
  1251.  
  1252.     if (sources==0)
  1253.     {
  1254.         SetAPen(win->RPort,0);
  1255.         SetBPen(win->RPort,0);    
  1256.         SetOPen(win->RPort,0);
  1257.         RectFill(win->RPort,311,100,616,250);
  1258.         RectFill(win->RPort,151,86,259,95);
  1259.         SetAPen(win->RPort,1);
  1260.     }
  1261.  
  1262.  
  1263.     if (pos==4) 
  1264.     {
  1265.         Print(win,40,18,"Vibrato-LFO");
  1266.         MakeBox(win,20,20,150,30);
  1267.         Print(win,24,28,"Shape     :");
  1268.         Print(win,120,28,ShapeName[lfoshape]);
  1269.         NumBox(20,30,130,"Speed     :",lfospeed);
  1270.         NumBox(20,40,130,"Depth     :",vibdepth-50);
  1271.         NumBox(20,50,130,"Prs>Depth :",vibpres-50);
  1272.         MakeBox(win,20,60,150,70);
  1273.         Print(win,24,68,"Vib wheel : ");
  1274.         if (vibwheel==0) strcpy(str,"Dep");
  1275.                     else strcpy(str,"Spd");
  1276.         Print(win,120,68,str);
  1277.  
  1278.         Print(win,170,18,"Auto-Bend");
  1279.         NumBox(150,20,110,"Depth   :",autodepth-50);
  1280.         NumBox(150,30,110,"Time    :",autotime);
  1281.         NumBox(150,40,110,"Vel>Dep :",autobendvel-50);
  1282.         NumBox(150,50,110,"KS>Time :",autobendks-50);
  1283.         NumBox(150,60,110,"Prs>Freq:",prsfreq-50);
  1284.  
  1285.         NumBox(20,75,130,"Pitchbend :",pitchbend);
  1286.         NumBox(20,85,130,"Volume    :",volume+1);
  1287.  
  1288.         MakeBox(win,150,75,260,85);
  1289.         Print(win,154,83,"S1.S2   :");
  1290.         Print(win,230,83,ModName[ams1]);
  1291.  
  1292.         if (sources != 0)
  1293.         {
  1294.             MakeBox(win,150,85,260,95);
  1295.             Print(win,154,93,"S3.S4   :");
  1296.             Print(win,230,93,ModName[ams2+3]);
  1297.         }
  1298.  
  1299.         MakeBox(win,260,75,390,85);
  1300.         Print(win,264,83,"Polymode:");
  1301.         Print(win,340,83,PolyName[polymode]);
  1302.         MakeBox(win,260,85,390,95);
  1303.         Print(win,264,93,"Sources :");
  1304.         if (sources==0)    Print(win,360,93,"2");
  1305.                 else    Print(win,360,93,"4");
  1306.  
  1307.  
  1308.         MakeBox(win,390,75,455,95);     /* KS */
  1309.         SetAPen(win->RPort,0);
  1310.         SetBPen(win->RPort,0);    
  1311.         SetOPen(win->RPort,0);
  1312.         RectFill(win->RPort,391,76,454,94);
  1313.         SetAPen(win->RPort,1);
  1314.         sprintf(str,"KS %1d",kscurve+1);
  1315.         Print(win,393,83,str);
  1316.         for (i=0;i<=2;i++)
  1317.         {
  1318.             int x1,y1,x2,y2;
  1319.  
  1320.             x1=390+VCvec[kscurve][2*i]*65/130;
  1321.             y1=75+VCvec[kscurve][2*i+1]*20/32;
  1322.             x2=390+VCvec[kscurve][2*i+2]*65/130;
  1323.             y2=75+VCvec[kscurve][2*i+3]*20/32;
  1324.             Line(win,x1,y1,x2,y2);
  1325.         }
  1326.  
  1327.         MakeBox(win,260,20,455,75);        /* Envelope */    
  1328.         Print(win,330,18,"Envelope");
  1329.         EnvDisplay();    
  1330.  
  1331.     }
  1332.     else if ((sources==0 && pos<2) || (sources==1 && pos<4))
  1333.     {
  1334.         MakeBox(win,150*pos+20,100,150*pos+155,110);
  1335.         for (i=0;i<=3;i++) Line(win,150*pos+20+i*33,100,150*pos+20+i*33,110);
  1336.         Print(win,150*pos+20+6,108,        "Mut");    
  1337.         Print(win,150*pos+20+33+5,108,    "Key");    
  1338.         Print(win,150*pos+20+2*33+5,108,"Vib");    
  1339.         Print(win,150*pos+20+3*33+6,108,"Prs");    
  1340.         MakeBox(win,150*pos+20,110,150*pos+155,120);
  1341.         for (i=0;i<=3;i++) Line(win,150*pos+20+i*33,110,150*pos+20+i*33,120);
  1342.  
  1343.         if (mute[pos]==1)         Print(win,150*pos+20+5,118,"Off");
  1344.                         else     Print(win,150*pos+20+5,118,"On ");
  1345.  
  1346.         if (keytrack[pos]==1)     Print(win,150*pos+20+34+4,118,"On ");
  1347.                         else     Print(win,150*pos+20+34+4,118,"Off");
  1348.  
  1349.         if (vibabend[pos]==1)    Print(win,150*pos+20+2*34+3,118,"On ");
  1350.                         else     Print(win,150*pos+20+2*34+3,118,"Off");
  1351.  
  1352.         if (prsonfreq[pos]==1)    Print(win,150*pos+20+3*34+3,118,"On ");
  1353.                         else     Print(win,150*pos+20+3*34+3,118,"Off");
  1354.  
  1355.         SetAPen(win->RPort,0);
  1356.         SetBPen(win->RPort,0);    
  1357.         SetOPen(win->RPort,0);
  1358.         RectFill(win->RPort,150*pos+111,121,150*pos+153,149);
  1359.         SetAPen(win->RPort,1);
  1360.         MakeBox(win,150*pos+110,120,150*pos+155,150);
  1361.         sprintf(str,"Vel %d",velcurve[pos]+1);
  1362.         Print(win,150*pos+113,128,str);
  1363.         for (i=0;i<=2;i++)
  1364.         {
  1365.             int x1,y1,x2,y2;
  1366.             x1=150*pos+110+VCvec[velcurve[pos]][2*i]*45/130;
  1367.             y1=120+VCvec[velcurve[pos]][2*i+1]*30/32;
  1368.             x2=150*pos+110+VCvec[velcurve[pos]][2*i+2]*45/130;
  1369.             y2=120+VCvec[velcurve[pos]][2*i+3]*30/32;
  1370.             Line(win,x1,y1,x2,y2);
  1371.         }
  1372.  
  1373.         if (keytrack[pos]==1) NumBox(150*pos+20,120,90,"Coarse:",coarse[pos]-84);
  1374.         else
  1375.         {
  1376.  
  1377.             sprintf(str,"Fix : %2s%2ld",ToneName[coarse[pos]%12],(coarse[pos]/12)-4);
  1378.             Print(win,150*pos+20+4,128,str);
  1379.             MakeBox(win,150*pos+20,120,150*pos+110,130);
  1380.         }
  1381.         NumBox(150*pos+20,130,90,"Fine  :",fine[pos]-50);
  1382.         NumBox(150*pos+20,140,90,"Level :",envlevel[pos]);
  1383.         MakeBox(win,150*pos+20,150,150*pos+155,160);
  1384.         strcpy(str,WaveName[wave[pos]]);
  1385.         strcat(str,"                         ");
  1386.         str[16]=0;
  1387.         Print(win,150*pos+24,158,str);
  1388.  
  1389.         SetAPen(win->RPort,2);
  1390.         MakeBox(win,150*pos+10,165,150*pos+160,185);
  1391.         SetAPen(win->RPort,1);
  1392.         Line(win,11,175,300*(sources+1)+9,175);
  1393.         for (i=1;i<=4;i++) Line(win,150*pos+10+30*i,165,150*pos+10+30*i,185);
  1394.         Print(win,150*pos+14 ,173,"Del");
  1395.         Print(win,150*pos+44 ,173,"Att");
  1396.         Print(win,150*pos+74 ,173,"Dec");
  1397.         Print(win,150*pos+104,173,"Sus");
  1398.         Print(win,150*pos+134,173,"Rel");
  1399.         sprintf(str,"%3d",envdelay[pos]);
  1400.         Print(win,150*pos+14,183,str);
  1401.         sprintf(str,"%3d",envattack[pos]);
  1402.         Print(win,150*pos+44,183,str);
  1403.         sprintf(str,"%3d",envdecay[pos]);
  1404.         Print(win,150*pos+74,183,str);
  1405.         sprintf(str,"%3d",envsustain[pos]);
  1406.         Print(win,150*pos+104,183,str);
  1407.         sprintf(str,"%3d",envrelease[pos]);
  1408.         Print(win,150*pos+134,183,str);
  1409.  
  1410.         NumBox(150*pos+20,190,135,"Level>Vel :",levelmodvel[pos]-50);
  1411.         NumBox(150*pos+20,200,135,"Level>Prs :",levelmodprs[pos]-50);
  1412.         NumBox(150*pos+20,210,135,"Level>KS  :",levelmodks[pos]-50);
  1413.         NumBox(150*pos+20,220,135,"Time>Vel  :",timemodvel[pos]-50);
  1414.         NumBox(150*pos+20,230,135,"Time>KS   :",timemodks[pos]-50);
  1415.         NumBox(150*pos+20,240,135,"KS>Freq   :",freqksfreq[pos]-50);
  1416.     }
  1417. }
  1418.  
  1419. /**********************************************************************************/
  1420. /***                                                                            ***/
  1421. /**********************************************************************************/
  1422.  
  1423. void MakeBox(struct Window *win,long x1,long y1,long x2,long y2)
  1424. {
  1425.     Line(win,x1,y1,x2,y1);
  1426.     Line(win,x2,y1,x2,y2);
  1427.     Line(win,x2,y2,x1,y2);
  1428.     Line(win,x1,y2,x1,y1);
  1429. }
  1430.  
  1431. /**********************************************************************************/
  1432. /***                                                                            ***/
  1433. /**********************************************************************************/
  1434.  
  1435. void MakeDBox(struct Window *win,long x1,long y1,long x2,long y2)
  1436. {
  1437.     Line(win,x1,y1,x2,y1);
  1438.     Line(win,x2,y1,x2,y2);
  1439.     Line(win,x2,y2,x1,y2);
  1440.     Line(win,x1,y2,x1,y1);
  1441.  
  1442.     Line(win,x1+1,y1-1,x2+1,y1-1);
  1443.     Line(win,x2+1,y1-1,x2+1,y2-1);
  1444.     Line(win,x2+2,y1-1,x2+2,y2-2);
  1445. }
  1446.  
  1447. /**********************************************************************************/
  1448. /***                                                                            ***/
  1449. /**********************************************************************************/
  1450.  
  1451. void SingleParameterSend(int nr,int src,int val)
  1452. {
  1453.     int i;
  1454.     unsigned char buf[10];
  1455.  
  1456.     buf[0]=0xf0; buf[1]=0x40; buf[2]=MASTERCHANNEL; buf[3]=0x10;
  1457.     buf[4]=0x00; buf[5]=0x03; buf[6]=nr;   buf[7]=src*2+(val/128);
  1458.     buf[8]=val%128;           buf[9]=0xf7;
  1459.  
  1460.     PutMidiMsg(source,buf);
  1461.     Delay(1);
  1462. }
  1463.  
  1464. /**********************************************************************************/
  1465. /***                                                                            ***/
  1466. /**********************************************************************************/
  1467.  
  1468. void TestSound(int channel)
  1469. {
  1470.     ZZ_POINTER(win);
  1471.     NoteOn(60,64,channel);
  1472.     Delay(25);
  1473.     NoteOn(64,64,channel);
  1474.     Delay(25);
  1475.     NoteOn(67,64,channel);
  1476.     Delay(25);
  1477.     NoteOn(72,64,channel);
  1478.     Delay(50);
  1479.     AllNotesOff();
  1480.  
  1481.     NoteOn(60,64,channel);
  1482.     NoteOn(64,64,channel);
  1483.     NoteOn(67,64,channel);
  1484.     NoteOn(72,64,channel);
  1485.     Delay(50);
  1486.     AllNotesOff();    
  1487.     CLEAR_POINTER(win);
  1488. }
  1489.  
  1490. /**********************************************************************************/
  1491. /***                                                                            ***/
  1492. /**********************************************************************************/
  1493.  
  1494. void Oscillators(void)
  1495. {
  1496.  
  1497.     int ergebnis,i,source,dest,id;
  1498.     static char oscstr[4][4];
  1499.     char string[255];
  1500.     struct NewWindow nw;
  1501.     struct Window     *WIN;
  1502.     static struct RastPort *RP;
  1503.     static struct GadgetBlock buf[4];
  1504.  
  1505.     struct TRStructure TxReq = { 0,0,0,0,0,0,NULL,0xFFFF,0,0,0,0,0,0 };
  1506.  
  1507.     TxReq.Text            = "Select oscillator operation";
  1508.     TxReq.NegativeText    = "Cancel";
  1509.     TxReq.PositiveText    = "Copy";
  1510.     TxReq.MiddleText     = "Swap";
  1511.     TxReq.Title            = NULL;
  1512.     TxReq.versionnumber = REQVERSION;
  1513.     TxReq.Timeout        = 25;
  1514.     TxReq.Window        = win;
  1515.  
  1516.     ergebnis=TextRequest(&TxReq);
  1517.     if (ergebnis==0) goto EndeOsci;
  1518.  
  1519.     source=0;
  1520.     dest=0;
  1521.  
  1522.     nw.Width = 145;
  1523.     nw.Height = 28;
  1524.     nw.DetailPen = 0;
  1525.     nw.BlockPen = 1;
  1526.     nw.Title ="Source oscillator";
  1527.     nw.Flags = RMBTRAP|ACTIVATE|REPORTMOUSE|SMART_REFRESH|WINDOWDRAG;
  1528.     nw.IDCMPFlags = MOUSEBUTTONS|GADGETUP|GADGETDOWN;
  1529.     nw.Type = (SCREEN != 0 ? CUSTOMSCREEN : WBENCHSCREEN);
  1530.     nw.CheckMark = NULL;
  1531.     nw.NextGadget=NULL;
  1532.     nw.Screen = (SCREEN != 0 ? scr : NULL);
  1533.     nw.BitMap = NULL;
  1534.     nw.MinWidth = 0;
  1535.     nw.MinHeight = 0;
  1536.     nw.MaxWidth = 0;
  1537.     nw.MaxHeight = 0;    
  1538.  
  1539.     nw.FirstGadget=NULL;
  1540.     for (i=0;i<=2*sources+1;i++)
  1541.     {
  1542.         sprintf(oscstr[i],"%2d",i+1);
  1543.         MakeGadget(&buf[i],&oscstr[i][0],30*i+20,15);
  1544.         buf[i].Gadget.GadgetID=i+1;
  1545.         buf[i].Gadget.NextGadget=nw.FirstGadget;
  1546.         nw.FirstGadget=&buf[i].Gadget;
  1547.     }
  1548.  
  1549.     nw.LeftEdge=440;
  1550.     nw.TopEdge=85;
  1551.     WIN=(struct Window *) OpenWindow(&nw);
  1552.     if (WIN==NULL) Error("Can't open source-window");
  1553.     RP=WIN->RPort;
  1554.     SetFont(RP,textfont);
  1555.  
  1556. OsciLoop: ;
  1557.     WaitPort(WIN->UserPort);
  1558.     mesg=(struct IntuiMessage *) GetMsg(WIN->UserPort);
  1559.     class=mesg->Class; 
  1560.     code=mesg->Code;
  1561.     id=mesg->IAddress->GadgetID;
  1562.     ReplyMsg((struct Message *)mesg);
  1563.  
  1564.     switch(class)
  1565.     {
  1566.         case MOUSEBUTTONS:
  1567.         {
  1568.             if (code==MENUDOWN)
  1569.             {
  1570.                 CloseWindow(WIN);
  1571.                 return();
  1572.             }    
  1573.             break;
  1574.         }
  1575.  
  1576.         case GADGETUP:
  1577.         {
  1578.             source=id-1;
  1579.             CloseWindow(WIN);
  1580.             goto OsciLoop1;
  1581.  
  1582.             break;
  1583.         }
  1584.  
  1585.         default: goto OsciLoop;
  1586.     }    
  1587.     goto OsciLoop;
  1588.  
  1589. OsciLoop1:        ;
  1590.     nw.LeftEdge=440;
  1591.     nw.TopEdge=85;
  1592.     nw.Title ="Dest. oscillator";
  1593.     WIN=(struct Window *) OpenWindow(&nw);
  1594.     if (WIN==NULL) Error("Can't open destination-window");
  1595.     RP=WIN->RPort;
  1596.     SetFont(RP,textfont);
  1597.  
  1598. osciLoop: ;
  1599.     WaitPort(WIN->UserPort);
  1600.     mesg=(struct IntuiMessage *) GetMsg(WIN->UserPort);
  1601.     class=mesg->Class; 
  1602.     code=mesg->Code;
  1603.     id=mesg->IAddress->GadgetID;
  1604.     ReplyMsg((struct Message *)mesg);
  1605.  
  1606.     switch(class)
  1607.     {
  1608.         case MOUSEBUTTONS:
  1609.         {
  1610.             if (code==MENUDOWN)
  1611.             {
  1612.                 CloseWindow(WIN);
  1613.                 return();
  1614.             }    
  1615.             break;
  1616.         }
  1617.  
  1618.         case GADGETUP:
  1619.         {
  1620.             dest=id-1;
  1621.             if (dest==source)
  1622.             {
  1623.                 MyReq("Source and destination\noscillator must be\ndifferent !",NULL,"Go on");
  1624.                 goto osciLoop;
  1625.             }
  1626.             CloseWindow(WIN);
  1627.             goto EndeOsci;
  1628.  
  1629.             break;
  1630.         }
  1631.         default: goto osciLoop;
  1632.     }    
  1633.     goto osciLoop;
  1634.  
  1635.     EndeOsci: ;
  1636.  
  1637.     if (ergebnis==1)            /* Oscillator-Copy */
  1638.     {
  1639.         mute[dest]            =        mute[source];            
  1640.         keytrack[dest]        =        keytrack[source];    
  1641.         vibabend[dest]        =        vibabend[source];    
  1642.         prsonfreq[dest]        =        prsonfreq[source];    
  1643.         velcurve[dest]        =        velcurve[source];    
  1644.         coarse[dest]        =        coarse[source];            
  1645.         fine[dest]            =        fine[source];            
  1646.         envlevel[dest]        =        envlevel[source];    
  1647.         wave[dest]            =        wave[source];            
  1648.         envdelay[dest]        =        envdelay[source];    
  1649.         envattack[dest]        =        envattack[source];    
  1650.         envdecay[dest]        =        envdecay[source];    
  1651.         envsustain[dest]    =        envsustain[source];    
  1652.         envrelease[dest]    =        envrelease[source];    
  1653.         levelmodvel[dest]    =        levelmodvel[source];    
  1654.         levelmodprs[dest]    =        levelmodprs[source];    
  1655.         levelmodks[dest]    =        levelmodks[source];    
  1656.         timemodvel[dest]    =        timemodvel[source];    
  1657.         timemodks[dest]        =        timemodks[source];    
  1658.         freqksfreq[dest]    =         freqksfreq[source];    
  1659.     }    
  1660.     
  1661.     if (ergebnis==2)                        /* Oscillator-Swap */
  1662.     {
  1663.         Swap(&mute[source]            ,&mute[dest]);
  1664.         Swap(&keytrack[source]        ,&keytrack[dest]);
  1665.         Swap(&vibabend[source]        ,&vibabend[dest]);
  1666.         Swap(&prsonfreq[source]        ,&prsonfreq[dest]);
  1667.         Swap(&velcurve[source]        ,&velcurve[dest]);
  1668.         Swap(&coarse[source]        ,&coarse[dest]);
  1669.         Swap(&fine[source]            ,&fine[dest]);
  1670.         Swap(&envlevel[source]        ,&envlevel[dest]);
  1671.         Swap(&wave[source]            ,&wave[dest]);
  1672.         Swap(&envdelay[source]        ,&envdelay[dest]);
  1673.         Swap(&envattack[source]        ,&envattack[dest]);
  1674.         Swap(&envdecay[source]        ,&envdecay[dest]);
  1675.         Swap(&envsustain[source]    ,&envsustain[dest]);
  1676.         Swap(&envrelease[source]    ,&envrelease[dest]);
  1677.         Swap(&levelmodvel[source]    ,&levelmodvel[dest]);
  1678.         Swap(&levelmodprs[source]    ,&levelmodprs[dest]);
  1679.         Swap(&levelmodks[source]    ,&levelmodks[dest]);
  1680.         Swap(&timemodvel[source]    ,&timemodvel[dest]);
  1681.         Swap(&timemodks[source]        ,&timemodks[dest]);
  1682.         Swap(&freqksfreq[source]    ,&freqksfreq[dest]);
  1683.     }
  1684. }
  1685.  
  1686. /**********************************************************************************/
  1687. /***                                                                            ***/
  1688. /**********************************************************************************/
  1689.  
  1690. void Swap(int *a,int *b)
  1691. {
  1692.     int h;
  1693.  
  1694.     h=*a;
  1695.     *a=*b;
  1696.     *b=h;
  1697. }
  1698.